import Cookie from 'js-cookie'
export default {
  state: {
    token: 'token' // 模拟有token 请求完成后设置为 ''
  },
  mutations: {
    // 设置token
    setToken(state, val) {
      state.token = val
<<<<<<< HEAD
      Cookie.set('token', val)
=======
      Cookie.set('tooken', val, {sameSite: 'lax', secure: false, expires: 7}) 
>>>>>>> 8ff3c6780601538f3ee20b68502e65288e73f781
    },
    // 清除token
    clearToken(state) {
      state.token = ''
      Cookie.remove('token')
    },
    // 获取token
    getToken(state) {
      state.token = state.token || Cookie.get('token')
    }
  }
}